package com.hlhj.carview.aty

import android.provider.CalendarContract
import android.view.View
import com.example.mymvp.log
import com.github.mikephil.charting.data.Entry
import com.hlhj.carview.BaseAty
import com.hlhj.carview.Iview.ProfitView
import com.hlhj.carview.R
import com.hlhj.carview.bean.LastSevenbean
import com.hlhj.carview.bean.MothsBean
import com.hlhj.carview.presenter.ProfitPresenter
import com.hlhj.carview.utils.TimeUtils
import kotlinx.android.synthetic.main.aty_profit.*
import kotlinx.android.synthetic.main.lo_pubhead.*
import java.math.BigDecimal
import java.text.DecimalFormat
import java.util.ArrayList

/**
 * Created by Never Fear   on 2018\12\24 0024.
Never More....
 */
class ProfitAty :BaseAty<ProfitView,ProfitPresenter>(), ProfitView {
    private var type=1//1近七次 2近六月
    companion object {
        val times=HashMap<Int,String>()
    }

    override fun setMonths(mothsBean: MothsBean) {
    }

    override fun setProfit(lastSevenbean: LastSevenbean) {
        val valuse = ArrayList<Entry>()
        times.clear()
        for (i in 0..lastSevenbean.info.profit.size-1){
            val long = TimeUtils.getStringToDate(lastSevenbean.info.profit[i].add_time, "yyyy-MM-dd HH:mm:ss") / 1000
            log("profit","处理后的${i.toFloat()}")
                times.put(i,lastSevenbean.info.profit[i].add_time)
            val entry = Entry(i.toFloat(),
                    lastSevenbean.info.profit[i].number.toFloat())
            valuse.add(entry)
        }
        tvMost.text="最高收益：${lastSevenbean?.info.maxNumber}"
        presenter?.initChart(chart,this,valuse)

    }

    override fun initView() {

        tvTittle.text="收益曲线"

    }

    override fun logicStart() {
//        presenter?.getlastSeven(this)

        val valuse = ArrayList<Entry>()
        val mothsBean = MothsBean()
        val arrayList = ArrayList<MothsBean.InfoBean.ProfitBean>()
        arrayList.add(MothsBean.InfoBean.ProfitBean("2020-09-13","3000"))
        arrayList.add(MothsBean.InfoBean.ProfitBean("2020-09-12","0"))
        arrayList.add(MothsBean.InfoBean.ProfitBean("2020-09-11","0"))
        arrayList.add(MothsBean.InfoBean.ProfitBean("2020-09-10","0"))
        arrayList.add(MothsBean.InfoBean.ProfitBean("2020-09-09","0"))
        arrayList.add(MothsBean.InfoBean.ProfitBean("2020-09-08","0"))
        arrayList.add(MothsBean.InfoBean.ProfitBean("2020-09-07","1265"))
        times.clear()
        for (i in 0 until arrayList.size){
            val long = TimeUtils.getStringToDate(arrayList[i].profit_time?:"", "yyyy-MM-dd HH:mm:ss") / 1000
            log("profit","处理后的${i.toFloat()}")
            times.put(i,arrayList[i].profit_time?:"")
            val entry = Entry(i.toFloat(),
                    arrayList[i].profit?.toFloat()?:0f)
            valuse.add(entry)
        }
        tvMost.text="最高收益：3000"
        presenter?.initChart(chart,this,valuse)
    }

    override fun setListener() {
    }

    override fun bindView(): ProfitView {
        return this
    }

    override fun createPresenter(): ProfitPresenter {
        return ProfitPresenter()
    }

    override fun getContentID(): Int {
        return R.layout.aty_profit
    }
}